<?php
/**
 * 部门管理
 * 
 * @author  Lee <a605333742@gmail.com>
 * @time    2016-07-13
 */
namespace Home\Controller;

class SectionController extends AllowController{
    /*
     * 构造函数
     *
     * @return  #
     */
    public function _initialize(){       
        parent::_initialize();
        $this->db_sec       =D("Section");
        $this->db_notice    =D('Notice');
        $this->db_user      =D('User');
    }
    
    /*
     * 部门列表
     * 
     * @return  #
     */
    public function index(){
        $where=array(
            "status"    =>1,
            'id'        =>array('neq',1)
        );
        $ord['add_time']=desc;
        $secList        =$this->db_sec->sectionList($where,$ord,20);
        $sectionList    =$secList['secList'];
        $pageList       =$secList['pageList'];
        $this->assign("sList",$sectionList);
        $this->assign("pageList",$pageList);
        $this->display();
    }
    
    /*
     * 部门公告列表
     * 
     * @return  #
     */
    public function secNotice(){
        $where=array(
            "status"    =>1,
            "section_id"=>$_SESSION['home']['section_id'],
        );    
        $ord['change_time']=desc;
        $sec_List   =$this->db_notice->showList($where,$ord,5,1);
        $sec_notic  =$sec_List['noticeList'];
        $pageList   =$sec_List['pageList'];
        //$enPage     =enPage($pageList,$sec_notic,5);
        $this->assign("sNotice",$sec_notic);
        $this->assign("pageList",$pageList);
        $this->display();
    }
    
    /*
     * 部门成员列表
     * 
     * @return # 
     */
    public function secStaff(){
        $where=array(
            "status"    =>1,
            "section_id"=>I("request.id"),
        );
        $ord['add_time']=desc;
        $userList   =$this->db_user->userList($where,$ord,10,1);
        $uList      =$userList['userList'];
        $pageList   =$userList['pageList'];
        //$enPage     =enPage($pageList);
        $this->assign("pageList",$pageList);
        $this->assign("uList",$uList);
        $this->display();
    }
    
    /*
     * 部门详细信息，部门简介
     * 
     * @return  #
     */
    public function secList(){
        $group_id       =I("request.group_id","","code");  
        $departmentInfo =$this->db_sec->find($group_id);
        //部门员工列表
        $userList       =$this->db_user->where(array("section_id"=>$group_id))->select();
        A("Club")->actList();
        $this->assign("userList",$userList);
        $this->assign("secInfo",$departmentInfo);
        $this->assign("userList",$userList);
        $this->display("Club/activityList");
    }
}

